package com.chookss.home.adapter;

import android.content.Context;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.chookss.R;
import com.chookss.base.BaseViewHolderEx;

import java.util.ArrayList;

public class ListAdapter extends BaseQuickAdapter<String, BaseViewHolderEx> {
    private Context context;
  private int index;
    public ListAdapter(int layoutResId, Context context, @io.reactivex.annotations.Nullable ArrayList<String> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolderEx helper, String entity) {
        TextView diretoryTv = helper.getView(R.id.diretory);
        diretoryTv.setText(entity);
        if (index == helper.getItemPosition()) {
            diretoryTv.setSelected(true);
        } else {
            diretoryTv.setSelected(false);
        }
    }
   public void setChoice(int index){
       this.index=index;
       notifyDataSetChanged();
   }
}
